import 'package:flutter/material.dart';

class RouteUtils {
  // 打开页面
  static void pushPage(BuildContext context, Widget page) {
    if (page == null) return;
    Navigator.of(context)
        .push(MaterialPageRoute(builder: (BuildContext context) => page));
  }

  // 打开页面，并切换当前页面
  static void pushRePage(BuildContext context, Widget page) {
    if (page == null) return;
    Navigator.of(context).pushReplacement(
        MaterialPageRoute(builder: (BuildContext context) => page));
  }

  // 关闭当前页面
  static void popPage(BuildContext context, Widget page) {
    if (page == null) return;
    Navigator.pop(context);
  }
}
